<template>
	<div class="app-container">

		<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="88px">
			<el-form-item label="订单编号" prop="orderId">
				<el-input v-model="queryParams.orderId" placeholder="请输入订单编号" clearable size="small"
					@keyup.enter.native="handleQuery" />
			</el-form-item>
			<el-form-item label="供应商" prop="supplierId">
				<el-select v-model="queryParams.supplierId" placeholder="请选择供应商" filterable clearable>
				  <el-option
				    v-for="item in supplierList"
				    :key="item.id"
				    :label="item.NAME"
				    :value="item.id">
				  </el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="时间" prop="differencetime">
				<el-select v-model="queryParams.differencetime" placeholder="请选择时间" clearable="">
				  <el-option label="3小时" value="3" />
				  <el-option label="5小时" value="5" />
				  <el-option label="8小时" value="8" />
				  <el-option label="12小时" value="12" />
				  <el-option label="24小时" value="24" />
				</el-select>
			</el-form-item>
			<el-form-item>
				<el-button type="cyan" icon="el-icon-search" size="small" @click="handleQuery">搜索</el-button>
				<el-button icon="el-icon-refresh" size="small" @click="resetQuery">重置</el-button>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" size="small" @click="exportIt()">导出</el-button>
			</el-form-item>
		</el-form>
		<el-table v-loading="loading" :data="tastList">
			<!--      <el-table-column label="流程ID" align="center" prop="id"/>-->
			<el-table-column label="订单编号" align="center" prop="showId" />
			<el-table-column label="采购单位" align="center" prop="purchaseName" />
			<el-table-column label="下单人" align="center" prop="purchaseId" />
			<el-table-column label="下单时间" align="center" prop="createTime" />

			<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
				<template slot-scope="scope">
					<el-button size="mini" type="text" icon="el-icon-edit" @click="examineAndApprove (scope.row)">详情
					</el-button>
				</template>
			</el-table-column>
		</el-table>

		<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
			@pagination="getList" />

	</div>
</template>

<script>
	import {
		getOrderDetailItemPriceChange,
		getQuerySupplier,
		orderDetailItemPriceChange
	} from "@/api/admin.api";


	export default {
		name: "upDown",
		data() {
			return {
				id: '',
				definitionKey: '',
				businessKey: '',
				// 遮罩层
				loading: true,
				// 选中数组
				ids: [],
				// 非单个禁用
				single: true,
				// 非多个禁用
				multiple: true,
				// 显示搜索条件
				showSearch: true,
				// 总条数
				total: 0,
				// 请假表格数据
				tastList: [],
				// 弹出层标题
				title: "",
				// 是否显示弹出层
				open: false,
				// 查询参数
				queryParams: {
					orderId: '',
					timeDifference:'',
					pageNum: 1,
					pageSize: 10,
					supplierId:''
				},
				// 表单参数
				form: {
					formData: []
				},
				// 表单校验
				rules: {},
				supplierList:[]
			};
		},
		created() {
			this.getList();
			this.getQuerySupplierList()
		},
		methods: {
			exportIt(){
				this.$confirm('是否确认导出数据项?', '警告', {
				  confirmButtonText: '确定',
				  cancelButtonText: '取消',
				  type: 'warning'
				}).then(function () {
				  return orderDetailItemPriceChange()
				}).then(response => {
				  // this.download(response.msg)
				  
				  let downLoadEle = document.createElement("a");
				  const href = "/dlzldb/common/download?fileName=" + encodeURI(response.msg); //  URL对象
				  downLoadEle.href = href;
				  downLoadEle.download = '价格修改信息.xlsx'; //指定下载的文件名
				  document.body.appendChild(downLoadEle)
				  downLoadEle.click(); // 模拟点击
				  document.body.removeChild(downLoadEle)
				  URL.revokeObjectURL(href); // 释放URL 对象
				  
				})
			},
		   getQuerySupplierList(){
			   getQuerySupplier({
				   current: 1,
				   size: 999999999
			   }).then(res=>{
				   console.log(res);
				   this.supplierList = res.records;
			   })
		   },
			/** 审批按钮操作 */
			examineAndApprove(row) {
				this.$router.push({
					path: "/priceDetail?id="+row.id+"&showId="+row.showId+"&type=2"
				})
			},
			/** 搜索按钮操作 */
			handleQuery() {
				this.queryParams.pageNum = 1;
				this.getList();
			},
			/** 重置按钮操作 */
			resetQuery() {
				this.resetForm("queryForm");
				this.handleQuery();
			},

			/** 查询请假列表 */
			getList() {
				this.loading = true;
				getOrderDetailItemPriceChange(this.queryParams).then(response => {
					this.tastList = response.rows;
					this.total = response.total;
					this.loading = false;
				});
			},
			// 表单重置
			reset() {
				this.definitionKey = '',
					this.businessKey = '',
					this.form = {
						formData: [],
					};
				this.resetForm("form");
			},
		}
	};
</script>
